ARG DOCKER_REGISTRY
FROM ${DOCKER_REGISTRY}/base/nginx-php-fpm-alpine:latest

RUN apk add --update --no-cache supervisor && \
    rm -rf /var/cache/apk/* /tmp/* /var/tmp/* ~/.pearrc

# Set up cron
#COPY cron/laravel /tmp/laravel
#RUN chmod 0644 /tmp/laravel \
#    && touch /var/log/cron.log \
#    && crontab /tmp/laravel -u www-data

RUN touch /var/log/cron.log && \
    chown -R www-data:www-data /var/log/cron.log && \
    echo '* * * * * /usr/local/bin/php /var/www/artisan schedule:run >> /var/log/cron.log 2>&1' >> /etc/crontabs/root && \
    echo '* * * * * echo 88888 >> /var/log/cron.log 2>&1' >> /etc/crontabs/root && \
    echo '#' >> /etc/crontabs/root

# Configure supervisord
COPY supervisord.conf /etc/supervisor/
COPY supervisor /etc/supervisor/conf.d/

COPY docker-entrypoint.sh /root/docker-entrypoint.sh
RUN chmod +x /root/docker-entrypoint.sh && \
    mkdir -p /var/log/supervisor/

ENTRYPOINT ["/root/docker-entrypoint.sh"]

EXPOSE 9000
